#include <stdio.h>

void test_one()
{
    /*1189:	f3 0f 1e fa          	endbr64 
    118d:	55                   	push   %rbp
    118e:	48 89 e5             	mov    %rsp,%rbp
    1191:	48 83 ec 20          	sub    $0x20,%rsp
    1195:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    119c:	00 00 
    119e:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    11a2:	31 c0                	xor    %eax,%eax
    11a4:	c7 45 ec 01 00 00 00 	movl   $0x1,-0x14(%rbp) */
		int a = 0x1;

    /*11ab:	48 8d 45 ec          	lea    -0x14(%rbp),%rax	// a
    11af:	48 89 45 f0          	mov    %rax,-0x10(%rbp)	// (rbp-0x10)=a  pointer */
		char *b = (char*)&a;

    /*11b3:	48 8b 45 f0          	mov    -0x10(%rbp),%rax	// rax = b
    11b7:	0f b6 00             	movzbl (%rax),%eax		// eax = *b, char
    11ba:	3c 01                	cmp    $0x1,%al			// 1 == *b		
    11bc:	75 0e                	jne    11cc <test_one+0x43>
    11be:	48 8d 3d 43 0e 00 00 	lea    0xe43(%rip),%rdi        # 2008 <_IO_stdin_used+0x8>
    11c5:	e8 a6 fe ff ff       	callq  1070 <puts@plt>
    11ca:	eb 0c                	jmp    11d8 <test_one+0x4f>
    11cc:	48 8d 3d 43 0e 00 00 	lea    0xe43(%rip),%rdi        # 2016 <_IO_stdin_used+0x16>
    11d3:	e8 98 fe ff ff       	callq  1070 <puts@plt>*/
		if (*b == 1) {
			printf("asdf\n");
		}
		else {
			printf("dddds\n");
		}

    /*11d8:	90                   	nop
    11d9:	48 8b 55 f8          	mov    -0x8(%rbp),%rdx
    11dd:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
    11e4:	00 00 
    11e6:	74 05                	je     11ed <test_one+0x64>
    11e8:	e8 93 fe ff ff       	callq  1080 <__stack_chk_fail@plt>
    11ed:	c9                   	leaveq 
    11ee:	c3                   	retq   */
}

int checkCPU()
{
    /*11ef:	f3 0f 1e fa          	endbr64 
    11f3:	55                   	push   %rbp
    11f4:	48 89 e5             	mov    %rsp,%rbp
    11f7:	c7 45 fc 01 00 00 00 	movl   $0x1,-0x4(%rbp) */ // int
	union ac
	{
		int a;
		char b;
	}d;

	d.a = 0x1;

    /*11fe:	0f b6 45 fc          	movzbl -0x4(%rbp),%eax	// char 对同一地址做不同操作，由此判定是联合体，也需多次验证才能还原
    1202:	3c 01                	cmp    $0x1,%al			// 
    1204:	0f 94 c0             	sete   %al				// 
    1207:	0f b6 c0             	movzbl %al,%eax
    120a:	5d                   	pop    %rbp
    120b:	c3                   	retq   */
	return (d.b == 1);
}

void test_two()
{
    /*120c:	f3 0f 1e fa          	endbr64 
    1210:	55                   	push   %rbp
    1211:	48 89 e5             	mov    %rsp,%rbp
    1214:	48 83 ec 10          	sub    $0x10,%rsp
    1218:	48 c7 45 f8 01 00 00 	movq   $0x1,-0x8(%rbp) */
		int *a = (int *)0x1;

    /*121f:	00 
    1220:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax = a
    1224:	48 83 c0 0c          	add    $0xc,%rax		// rax = a+0xc
    1228:	48 83 f8 01          	cmp    $0x1,%rax
    122c:	75 0e                	jne    123c <test_two+0x30>
    122e:	48 8d 3d ec 0d 00 00 	lea    0xdec(%rip),%rdi        # 2021 <_IO_stdin_used+0x21>
    1235:	e8 36 fe ff ff       	callq  1070 <puts@plt>
    123a:	eb 0c                	jmp    1248 <test_two+0x3c>
    123c:	48 8d 3d e2 0d 00 00 	lea    0xde2(%rip),%rdi        # 2025 <_IO_stdin_used+0x25>
    1243:	e8 28 fe ff ff       	callq  1070 <puts@plt>*/
		if ((unsigned long)&a[3] == 1) {
			printf("asdf\n");
		}
		else {
			printf("sssa\n");
		}

    /*1248:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    124c:	48 8d 70 14          	lea    0x14(%rax),%rsi
    1250:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1254:	4c 8d 40 10          	lea    0x10(%rax),%r8
    1258:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    125c:	48 8d 78 0c          	lea    0xc(%rax),%rdi
    1260:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1264:	48 8d 48 08          	lea    0x8(%rax),%rcx
    1268:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    126c:	48 8d 50 04          	lea    0x4(%rax),%rdx
    1270:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1274:	48 83 ec 08          	sub    $0x8,%rsp
    1278:	56                   	push   %rsi
    1279:	4d 89 c1             	mov    %r8,%r9
    127c:	49 89 f8             	mov    %rdi,%r8
    127f:	48 89 c6             	mov    %rax,%rsi
    1282:	48 8d 3d a7 0d 00 00 	lea    0xda7(%rip),%rdi        # 2030 <_IO_stdin_used+0x30>
    1289:	b8 00 00 00 00       	mov    $0x0,%eax
    128e:	e8 fd fd ff ff       	callq  1090 <printf@plt> */
		printf("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", (unsigned int)(long)&a[0], (unsigned int)(long)&a[1], 
												  (unsigned int)(long)&a[2], (unsigned int)(long)&a[3], 
												  (unsigned int)(long)&a[4], (unsigned int)(long)&a[5]);

    /*1293:	48 83 c4 10          	add    $0x10,%rsp
    1297:	90                   	nop
    1298:	c9                   	leaveq 
    1299:	c3                   	retq   */
}

void test_thr()
{
    /*129a:	f3 0f 1e fa          	endbr64 
    129e:	55                   	push   %rbp
    129f:	48 89 e5             	mov    %rsp,%rbp
    12a2:	48 83 ec 10          	sub    $0x10,%rsp
    12a6:	c7 45 fc 78 56 34 12 	movl   $0x12345678,-0x4(%rbp) */
	union ac
	{
		int ua;
		short ub;
	}a;

	a.ua = 0x12345678;

    /*12ad:	0f b7 45 fc          	movzwl -0x4(%rbp),%eax
    12b1:	66 3d 34 12          	cmp    $0x1234,%ax
    12b5:	75 0c                	jne    12c3 <test_thr+0x29>
    12b7:	48 8d 3d 63 0d 00 00 	lea    0xd63(%rip),%rdi        # 2021 <_IO_stdin_used+0x21>
    12be:	e8 ad fd ff ff       	callq  1070 <puts@plt>*/
	if (a.ub == 0x1234) {
		printf("ass\n");
	}

    /*12c3:	0f b7 45 fc          	movzwl -0x4(%rbp),%eax
    12c7:	66 3d 78 56          	cmp    $0x5678,%ax
    12cb:	75 0c                	jne    12d9 <test_thr+0x3f>
    12cd:	48 8d 3d 51 0d 00 00 	lea    0xd51(%rip),%rdi        # 2025 <_IO_stdin_used+0x25>
    12d4:	e8 97 fd ff ff       	callq  1070 <puts@plt>*/	
	if (a.ub == 0x5678) {
		printf("wwww\n");
	}

    /*12d9:	90                   	nop
    12da:	c9                   	leaveq 
    12db:	c3                   	retq   */
}

int test_four()
{
    /*12dc:	f3 0f 1e fa          	endbr64 
    12e0:	55                   	push   %rbp
    12e1:	48 89 e5             	mov    %rsp,%rbp
    12e4:	48 83 ec 20          	sub    $0x20,%rsp
    12e8:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    12ef:	00 00 
    12f1:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    12f5:	31 c0                	xor    %eax,%eax
    12f7:	48 8d 45 ec          	lea    -0x14(%rbp),%rax */	// rax=address
		int num;

    /*12fb:	48 89 45 f0          	mov    %rax,-0x10(%rbp)*/	// (rbp-0x10)=address
		int *p = &num;

    /*12ff:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%rbp)*/
		num = 0;

    /*1306:	48 8b 45 f0          	mov    -0x10(%rbp),%rax	// rax=address
    130a:	c6 00 ff             	movb   $0xff,(%rax)*/
		*(unsigned char*)p = 0xff;

    /*130d:	8b 45 ec             	mov    -0x14(%rbp),%eax
    1310:	3d ff 00 00 00       	cmp    $0xff,%eax
    1315:	75 0e                	jne    1325 <test_four+0x49>
    1317:	48 8d 3d 31 0d 00 00 	lea    0xd31(%rip),%rdi        # 204f <_IO_stdin_used+0x4f>
    131e:	e8 4d fd ff ff       	callq  1070 <puts@plt>
    1323:	eb 0c                	jmp    1331 <test_four+0x55>
    1325:	48 8d 3d 3f 0d 00 00 	lea    0xd3f(%rip),%rdi        # 206b <_IO_stdin_used+0x6b>
    132c:	e8 3f fd ff ff       	callq  1070 <puts@plt>*/
		if (num == 0xff) {
			printf("assd\n");
		}
		else {
			printf("fdsa\n");
		}
	
    /*1331:	b8 00 00 00 00       	mov    $0x0,%eax */
	return 0;

    /*1336:	48 8b 55 f8          	mov    -0x8(%rbp),%rdx
    133a:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
    1341:	00 00 
    1343:	74 05                	je     134a <test_four+0x6e>
    1345:	e8 36 fd ff ff       	callq  1080 <__stack_chk_fail@plt>
    134a:	c9                   	leaveq 
    134b:	c3                   	retq   */
}

int main()
{
    /*134c:	f3 0f 1e fa          	endbr64 
    1350:	55                   	push   %rbp
    1351:	48 89 e5             	mov    %rsp,%rbp
    1354:	48 83 ec 10          	sub    $0x10,%rsp
    1358:	c7 45 fc ff ff ff ff 	movl   $0xffffffff,-0x4(%rbp)*/
		int a = -1;

    /*135f:	e8 25 fe ff ff       	callq  1189 <test_one>
    1364:	b8 00 00 00 00       	mov    $0x0,%eax*/
		test_one();

    /*1369:	e8 81 fe ff ff       	callq  11ef <checkCPU>
    136e:	89 45 fc             	mov    %eax,-0x4(%rbp)*/
		a = checkCPU();

    /*1371:	83 7d fc 01          	cmpl   $0x1,-0x4(%rbp)
    1375:	75 0e                	jne    1385 <main+0x39>
    1377:	48 8d 3d 06 0d 00 00 	lea    0xd06(%rip),%rdi        # 2084 <_IO_stdin_used+0x84>
    137e:	e8 ed fc ff ff       	callq  1070 <puts@plt>
    1383:	eb 12                	jmp    1397 <main+0x4b>
    1385:	83 7d fc 00          	cmpl   $0x0,-0x4(%rbp)
    1389:	75 0c                	jne    1397 <main+0x4b>
    138b:	48 8d 3d 02 0d 00 00 	lea    0xd02(%rip),%rdi        # 2094 <_IO_stdin_used+0x94>
    1392:	e8 d9 fc ff ff       	callq  1070 <puts@plt>
    1397:	b8 00 00 00 00       	mov    $0x0,%eax*/
		if (a == 1) {
			printf("a\n");
		}
		else if (a == 0) {
			printf("b\n");
		}

    /*139c:	e8 6b fe ff ff       	callq  120c <test_two>
    13a1:	b8 00 00 00 00       	mov    $0x0,%eax*/
		test_two();

    /*13a6:	e8 ef fe ff ff       	callq  129a <test_thr>
    13ab:	b8 00 00 00 00       	mov    $0x0,%eax*/
		test_thr();

    /*13b0:	e8 27 ff ff ff       	callq  12dc <test_four>
    13b5:	b8 00 00 00 00       	mov    $0x0,%eax*/
		test_four();

    /*13ba:	c9                   	leaveq 
    13bb:	c3                   	retq   
    13bc:	0f 1f 40 00          	nopl   0x0(%rax)*/

	return 0;
}
